package com.jingxuan.util;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

/**
 * SearchKeywordProcessor 正确测试类
 */
public class CorrectSearchKeywordProcessorTest {

    @Test
    public void testBasicKeywordProcessing() {
        // 测试基本关键词处理
        SearchKeywordProcessor.KeywordInfo info = SearchKeywordProcessor.processKeyword("手机");
        
        assertEquals("手机", info.getOriginalKeyword());
        assertEquals("手机", info.getExactKeyword());
        assertEquals("手机%", info.getPrefixKeyword());
        assertEquals("%手机%", info.getFuzzyKeyword());
    }

    @Test
    public void testKeywordWithSuffix() {
        // 测试带后缀的关键词处理
        SearchKeywordProcessor.KeywordInfo info = SearchKeywordProcessor.processKeyword("苹果手机");
        
        assertEquals("苹果手机", info.getOriginalKeyword());
        // 精确匹配应该移除后缀"手机"
        assertEquals("苹果", info.getExactKeyword());
        assertEquals("苹果%", info.getPrefixKeyword());
        assertEquals("%苹果%", info.getFuzzyKeyword());
    }

    @Test
    public void testKeywordWithPrefix() {
        // 测试带前缀的关键词处理
        SearchKeywordProcessor.KeywordInfo info = SearchKeywordProcessor.processKeyword("官方苹果");
        
        assertEquals("官方苹果", info.getOriginalKeyword());
        // 精确匹配应该移除前缀"官方"
        assertEquals("苹果", info.getExactKeyword());
        assertEquals("苹果%", info.getPrefixKeyword());
        assertEquals("%苹果%", info.getFuzzyKeyword());
    }

    @Test
    public void testEmptyKeyword() {
        // 测试空输入
        SearchKeywordProcessor.KeywordInfo info = SearchKeywordProcessor.processKeyword("");
        
        assertEquals("", info.getOriginalKeyword());
        assertEquals("", info.getExactKeyword());
        assertEquals("", info.getPrefixKeyword());
        assertEquals("", info.getFuzzyKeyword());
    }

    @Test
    public void testNullKeyword() {
        // 测试null输入
        SearchKeywordProcessor.KeywordInfo info = SearchKeywordProcessor.processKeyword(null);
        
        assertEquals("", info.getOriginalKeyword());
        assertEquals("", info.getExactKeyword());
        assertEquals("", info.getPrefixKeyword());
        assertEquals("", info.getFuzzyKeyword());
    }
}